#ifndef __MAIN_H__
#define __MAIN_H__

#include "typedef.h"

#define WAIT_FOR_SLEEP_TIMER        ( 1000 / SYSTEM_TICK_PERIOD )

#define BEEP_SHORT_PERIOD       ( 60 / SYSTEM_TICK_PERIOD )
#define BEEP_LONG_PERIOD        ( 200 / SYSTEM_TICK_PERIOD )
#define WAITING_FOR_OFF_BEEP    ( 60 / SYSTEM_TICK_PERIOD )
#define WAITING_FOR_OFF_LED     ( 300 / SYSTEM_TICK_PERIOD )

#define BELL_COUNT_MAX          3
#define SS_UNACTIVE_COUNTER_MAX 20
#define BELL_BING_PERIOD        ( 300 / SYSTEM_TICK_PERIOD )
#define BELL_BONG_PERIOD        ( 700 / SYSTEM_TICK_PERIOD )
#define BELL_DELAY_PERIOD       ( 600 / SYSTEM_TICK_PERIOD )
#define BELL_DELAY_FOR_PREPARE  ( 2000 / SYSTEM_TICK_PERIOD )


#define SW_LEARNING_TIMEOUT     ( 5000 / SYSTEM_TICK_PERIOD )
#define SW_ERASE_TIMER          ( 2000 / SYSTEM_TICK_PERIOD )
#define TOGGLE_LED_TIMER        ( 250 / SYSTEM_TICK_PERIOD )

#define ALARM_LED_TOGGLE_TIMER  ( 300 / SYSTEM_TICK_PERIOD )    //chu ki chop led khi dang hu bao dong
#define WAIT_FOR_ALARM_LED      ( 10000 / SYSTEM_TICK_PERIOD )  //thoi gian sang led sau khi vo mode alarm
#define ALARM_ON_PERIOD         ( 25000 / SYSTEM_TICK_PERIOD )  //thoi gian hu bao dong trong 25 giay
#define ALARM_OFF_PERIOD        ( 3000 / SYSTEM_TICK_PERIOD )   //thoi gian cho sau khi hu bao dong

typedef enum _eMainState
{
    NORMAL,
    LEARNING,
    BELL,
    ALARM
} eMainState;
        
typedef enum _eNormalState
{
    NORMAL_INITRESET,
    NORMAL_PREPARE_FOR_WAITING,
    NORMAL_WAITING_FOR_EVENT
} eNormalState;

typedef enum _eLearningState
{
    LEARNING_INIT,
    LEARNING_WAITING_FOR_EVENT,
    LEARNING_ERASE,
    LEARNING_QUIT
} eLearningState;

typedef enum _eBellState
{
    BELL_INIT,
    BELL_DELAY,
    BELL_WAITING_FOR_EVENT,
    BELL_QUIT
} eBellState;

typedef enum _eBellProcessState
{
    BELL_PROCESS_IDLE,
    BELL_PROCESS_DELAY,
    BELL_PROCESS_BING,
    BELL_PROCESS_WAITING_FOR_BING,
    BELL_PROCESS_BONG,
    BELL_PROCESS_WAITING_FOR_BONG,
    BELL_PROCESS_CHECK_COMPLETE
} eBellProcessState;

typedef enum _eAlarmState
{
    ALARM_INIT,
    ALARM_WAITING_FOR_EVENT,
    ALARM_QUIT
} eAlarmState;

typedef enum _eAlarmProcessState
{
    ALARM_PROCESS_IDLE,
    ALARM_PROCESS_DELAY,
    ALARM_PROCESS_ALARM_ON,
    ALARM_PROCESS_WAIT_ALARM_ON,
    ALARM_PROCESS_ALARM_OFF,
    ALARM_PROCESS_WAIT_ALARM_OFF
} eAlarmProcessState;


#endif  //__MAIN_H__